package ru.jexp.rcp.supply.editor;

import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.dnd.DragSourceEvent;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.TreeDragSourceEffect;

import ru.jexp.rcp.supply.beans.project.dvs.sostavizdelia.TreePathMerge;

public class EkViewerDrag extends TreeDragSourceEffect
{

	private final TreeViewer viewer;

	public EkViewerDrag(TreeViewer viewer)
	{
		super(viewer.getTree());
		this.viewer = viewer;
	}

	
	@Override
	public void dragSetData(DragSourceEvent event)
	{
		IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
		TreePathMerge path = (TreePathMerge) selection.getFirstElement();

		if (path != null && path.getValue() != null)
		{
			event.doit = false;
			return;
		}

		if (!TextTransfer.getInstance().isSupportedType(event.dataType))
		{
			event.doit = false;
			return;
		}

		event.data = "tranfer data";
	}
	
	

}
